﻿using System;
using System.Collections.Generic;
using System.Text;
using Npgsql;
using System.Xml;


namespace CamadaAcessoBDPostgresql
{
    class DataConnection
    {
        public static string StringDeConexao
        {
            get
            {
                const string arquivo = @"...\conexao.xml";
                string Server = "Server=", Porta = "Port=", UserId = "UserId=", Password = "Password=", Database = "Database=", virgula = ";";



                XmlDocument doc = new XmlDocument();
                doc.Load(arquivo);

                XmlElement root = doc.DocumentElement;


                foreach (XmlNode node in root)
                {
                    switch (node.Name)
                    {
                        case "Server":
                            Server += node.InnerText;
                            break;

                        case "Porta":
                            Porta += node.InnerText;
                            break;


                        case "UserId":
                            UserId += node.InnerText;
                            break;

                        case "Password":
                            Password += node.InnerText;
                            break;

                        case "Database":
                            Database += node.InnerText;
                            break;

                    }





                }


                return Server + virgula + Porta + virgula + UserId + virgula + Password + virgula + Database + virgula;


            }
        }
    }
}
